/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author HoangHai
 */
@Entity
@Table(name = "Semester")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Semester.findAll", query = "SELECT s FROM Semester s"),
    @NamedQuery(name = "Semester.findSemIDByClassID", query = "SELECT DISTINCT s FROM Classes c JOIN c.resultList r JOIN r.classID s WHERE c.classID = :classID"),
    @NamedQuery(name = "Semester.findBySeID", query = "SELECT s FROM Semester s WHERE s.seID = :seID"),
    @NamedQuery(name = "Semester.findBySeName", query = "SELECT s FROM Semester s WHERE s.seName = :seName"),
    @NamedQuery(name = "Semester.findBySeDesc", query = "SELECT s FROM Semester s WHERE s.seDesc = :seDesc"),
    @NamedQuery(name = "Semester.findByCuID", query = "SELECT s FROM Semester s WHERE s.cuID.cuID = :cuID")})
public class Semester implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    //@NotNull
    @Column(name = "SeID")
    private Integer seID;
    @Size(max = 50)
    @Column(name = "SeName")
    private String seName;
    @Size(max = 1073741823)
    @Column(name = "SeDesc")
    private String seDesc;
    @OneToMany(mappedBy = "seID")
    private List<Result> resultList;
    @JoinColumn(name = "CuID", referencedColumnName = "CuID")
    @ManyToOne
    private Curriculum cuID;

    public Semester() {
    }

    public Semester(Integer seID) {
        this.seID = seID;
    }

    public Integer getSeID() {
        return seID;
    }

    public void setSeID(Integer seID) {
        this.seID = seID;
    }

    public String getSeName() {
        return seName;
    }

    public void setSeName(String seName) {
        this.seName = seName;
    }

    public String getSeDesc() {
        return seDesc;
    }

    public void setSeDesc(String seDesc) {
        this.seDesc = seDesc;
    }

    @XmlTransient
    public List<Result> getResultList() {
        return resultList;
    }

    public void setResultList(List<Result> resultList) {
        this.resultList = resultList;
    }

    public Curriculum getCuID() {
        return cuID;
    }

    public void setCuID(Curriculum cuID) {
        this.cuID = cuID;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (seID != null ? seID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Semester)) {
            return false;
        }
        Semester other = (Semester) object;
        if ((this.seID == null && other.seID != null) || (this.seID != null && !this.seID.equals(other.seID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Semester[ seID=" + seID + " ]";
    }
}
